package com.HQCourse.vod.vod.controller;


import com.HQCourse.result.Result;
import com.HQCourse.vod.vod.service.ChapterService;
import com.example.HQCourse.model.vod.Chapter;
import com.example.HQCourse.vo.vod.ChapterVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 课程 前端控制器
 * </p>
 *大纲列表
 * @author zww
 * @since 2023-06-25
 */
@RestController
@RequestMapping("admin/vod/chapter")
//@CrossOrigin
public class ChapterController {
    @Autowired
    private ChapterService chapterService;
    @ApiOperation("大纲列表方法")
    @GetMapping("getTreeList/{couresed}")
    private Result getList(@PathVariable Long couresed){
        List<ChapterVo> list= chapterService.getTreeList(couresed);
        return Result.ok(list);
    }
    @PostMapping("save")
    public Result save(@RequestBody Chapter chapter){
        chapterService.save(chapter);
        return Result.ok(null);
    }
    @GetMapping("get/{id}")
    public Result getChapterId(@PathVariable Long id){
        Chapter byId = chapterService.getById(id);
        return Result.ok(byId);
    }
    @PostMapping("update")
    public Result update(@RequestBody Chapter chapter){
        chapterService.updateById(chapter);
        return Result.ok(null);
    }
    @DeleteMapping("remove/{id}")
    public Result remove(@PathVariable Long id){
        chapterService.removeById(id);
        return Result.ok(null);
    }


}

